﻿using Bootstrap.Definition.Enums;
using Bootstrap.Helper;
using Bootstrap.Template.Label;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Bootstrap.Control
{
    [ToolboxData("<{0}:BootstrapLabel runat=server></{0}:BootstrapLabel>")]
    public class BootstrapLabel : WebControl
    {
        #region Properties
        
        public string Text { get; set; }
       
        public TypeEnum Type { get; set; }
        
        #endregion

        #region Methods
        
        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            var bootstrapLabelTemplateItem = new Bootstrap.Template.TemplateInnerItem.BootstrapLabelTemplateItem();

            bootstrapLabelTemplateItem.LabelType = ValueHelper.GetDefaultValue<TypeEnum>(this.Type, TypeEnum.Default);
            bootstrapLabelTemplateItem.Text = ValueHelper.GetDefaultValue<string>(this.Text, string.Empty) ;

            BootstrapLabelTemplate template = new BootstrapLabelTemplate(bootstrapLabelTemplateItem);

            writer.Write(template.TransformText());
        }

        #endregion
    }
}
